﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace APITwitter.Handlers
{
    public class Log
    {
        public static void Add(string content, string user, string ip, string agent)
        {
            using (SQLDBStoreDataContext sdc = new SQLDBStoreDataContext(Configuration.ConnectionString))
            {
                TwitterLog tl = new TwitterLog
                {
                    Agent = string.IsNullOrEmpty(agent) ? "unkown" : agent,
                    Content = content,
                    CreateDate = DateTime.Now,
                    IP = ip,
                    User = user,
                };

                sdc.TwitterLog.InsertOnSubmit(tl);
                sdc.SubmitChanges();
            }
        }

    }
}
